package work.jame.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import work.jame.blog.pojo.WhiteList;
import work.jame.blog.mapper.WhiteListMapper;
import work.jame.blog.service.WhiteListService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Jame
 * @since 2023-05-14
 */
@Service
public class WhiteListServiceImpl extends ServiceImpl<WhiteListMapper, WhiteList> implements WhiteListService {

    @Override
    public boolean queryWhiteListExistByIp(String ip) {
        QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
        wrapper.eq("ip", ip);
        return this.count(wrapper) == 1;
    }

    @Override
    public boolean queryWhiteListExistByUserId(Long userId) {
        QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        return this.count(wrapper) == 1;
    }
}
